package com.woniu.backstage.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.backstage.common.Result;
import com.woniu.backstage.entity.TbOrder;
import com.woniu.backstage.entity.form.OrderForm;
import com.woniu.backstage.service.ITbOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author spirit
 * @since 2020-04-18
 */
@RestController
@RequestMapping("/backstage/order")
public class TbOrderController extends BaseController {
    @Autowired
    private ITbOrderService orderService;

    @RequestMapping("/pageLimit")
    public Result pageLimit(Integer page, Integer limit, OrderForm orderForm){
        System.out.println("orderForm:"+orderForm);
        Page<TbOrder> orderPage = new Page<>(page, limit);
        IPage<TbOrder> orderIPage = orderService.pageLimit(orderPage,orderForm);
        //获取查询的数据
        List<TbOrder> orders = orderIPage.getRecords();
        System.out.println("orders:"+orders);
        //获取总的数据条数
        long total = orderIPage.getTotal();
        return Result.success(orders, (int) total);
    }
}

